package vip.xiaonuo.modular.vxpay.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import vip.xiaonuo.modular.vxpay.service.PaymentService;

@Configuration
public class WxPayConfiguration {


    @Bean
    public WxPayConfig payConfig() {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(PaymentService.APPID);
        payConfig.setMchId(PaymentService.MCH_ID);
        payConfig.setMchKey(PaymentService.API_KEY);
        payConfig.setKeyPath(PaymentService.certPath);
        return payConfig;
    }

    @Bean
    public WxPayService payService() {
        WxPayService payService = new WxPayServiceImpl();
        payService.setConfig(payConfig());
        return payService;
    }
}
